`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date:    16:27:53 10/21/2012 
// Design Name: 
// Module Name:    Display_Field 
// Project Name: 
// Target Devices: 
// Tool versions: 
// Description: 
//
// Dependencies: 
//
// Revision: 
// Revision 0.01 - File Created
// Additional Comments: 
//
//////////////////////////////////////////////////////////////////////////////////
module Display_Field(
		input game_Over, video_on, 
		input [9:0] pixel_x, pixel_y, ball_x, ball_y, paddle_y,         
		output reg[7:0] graph_rgb
);

	// constant and signal declaration
	// x,y coordinates (0,0) to (639,479)
	localparam [9:0] MAX_X = 640;
	localparam [9:0] MAX_Y = 400;	
	localparam [5:0] BORDER = 8;
	
	// paddle and ball
	localparam [5:0] PADDLEWIDTH = 5; //bits
	localparam [9:0] PADDLELONG = 82;
	localparam [9:0] PADDLE_X = 28; 
	localparam [5:0] BALL_SIZE = 5; // square ball
	
	// Logo Tec
	// T left, right, top, botton limites
	localparam LINE1_L = 250;
	localparam LINE1_R = 300;	
	localparam LINE1_T = 140;
	localparam LINE1_B = 150;
	
	localparam LINE2_L = 270;
	localparam LINE2_R = 280;	
	localparam LINE2_T = 150;//
	localparam LINE2_B = 220;
	
	// E
	localparam LINE3_L = 310;
	localparam LINE3_R = 320;
	localparam LINE3_B = 220;//
	localparam LINE3_T = 140;
	
	localparam LINE4_L = 320;
	localparam LINE4_R = 360;
	localparam LINE4_B = 150; // 
	localparam LINE4_T = 140; //
	
	localparam LINE5_L = 320;
	localparam LINE5_R = 350;
	localparam LINE5_B = 185;
	localparam LINE5_T = 175;
	
	localparam LINE6_L = 320;
	localparam LINE6_R = 360;
	localparam LINE6_B = 220;
	localparam LINE6_T = 210;
	
	// C
	localparam LINE7_L = 370;
	localparam LINE7_R = 420;
	localparam LINE7_T = 140;
	localparam LINE7_B = 150;
	
	localparam LINE8_L = 370;
	localparam LINE8_R = 380;
	localparam LINE8_T = 150;
	localparam LINE8_B = 220;
	
	localparam LINE9_L = 370;
	localparam LINE9_R = 420;
	localparam LINE9_T = 210;
	localparam LINE9_B = 220;
	
	
	wire wall_on , pad_on , ball_on, tec_on;
	wire [7:0] wall_rgb, pad_rgb, ball_rgb, tec_rgb;
	
	assign wall_on = ((MAX_X-BORDER <= pixel_x) || (pixel_y <= BORDER) || (MAX_Y-BORDER <= pixel_y));
	
	assign pad_on = ((PADDLE_X <= pixel_x) && (pixel_x <= PADDLE_X + PADDLEWIDTH) 
						 && (paddle_y <= pixel_y) && (pixel_y <= paddle_y + PADDLELONG));
						 
	assign ball_on = ((ball_x <= pixel_x) && (pixel_x <= ball_x + BALL_SIZE) 
						 && (ball_y <= pixel_y) && (pixel_y <= ball_y + BALL_SIZE));
						 
	assign tec_on = !game_Over && (
						 ((LINE1_L <= pixel_x) && (pixel_x <= LINE1_R) && (LINE1_T <= pixel_y) && (pixel_y <= LINE1_B)) ||
						 ((LINE2_L <= pixel_x) && (pixel_x <= LINE2_R) && (LINE2_T <= pixel_y) && (pixel_y <= LINE2_B)) ||
						 ((LINE3_L <= pixel_x) && (pixel_x <= LINE3_R) && (LINE3_T <= pixel_y) && (pixel_y <= LINE3_B)) ||
						 ((LINE4_L <= pixel_x) && (pixel_x <= LINE4_R) && (LINE4_T <= pixel_y) && (pixel_y <= LINE4_B)) ||
						 ((LINE5_L <= pixel_x) && (pixel_x <= LINE5_R) && (LINE5_T <= pixel_y) && (pixel_y <= LINE5_B)) ||
						 ((LINE6_L <= pixel_x) && (pixel_x <= LINE6_R) && (LINE6_T <= pixel_y) && (pixel_y <= LINE6_B)) ||
						 ((LINE7_L <= pixel_x) && (pixel_x <= LINE7_R) && (LINE7_T <= pixel_y) && (pixel_y <= LINE7_B)) ||
						 ((LINE8_L <= pixel_x) && (pixel_x <= LINE8_R) && (LINE8_T <= pixel_y) && (pixel_y <= LINE8_B)) ||
						 ((LINE9_L <= pixel_x) && (pixel_x <= LINE9_R) && (LINE9_T <= pixel_y) && (pixel_y <= LINE9_B)));
						 
	
						 
	assign wall_rgb = 8'b00000000; 
	assign pad_rgb  = 8'b00000011; 
	assign ball_rgb = 8'b00000011; 
	assign tec_rgb  = 8'b00000000; 

	always @*
		if (!video_on)
			graph_rgb = 8'b11001100; 
		else if (wall_on)
			graph_rgb = wall_rgb;
		else if (pad_on)
			graph_rgb = pad_rgb;
		else if (ball_on)
			graph_rgb = ball_rgb;
		else if (tec_on)
			graph_rgb = tec_rgb; 
		else 
			graph_rgb = 8'b00011100; 

endmodule
